package db;


import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;

import db.Dbhandle;
public class cauhoicoso implements Serializable{
	private String id;
	private String  MACAUHOI;
	private String NOIDUNG;
	private String MALINHVUC;
	private String MUCDO;
	private String A;
	private String B;
	private String C;
	private String D;
	private String DUNG;
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getMACAUHOI() {
		return MACAUHOI;
	}
	public void setMACAUHOI(String mACAUHOI) {
		MACAUHOI = mACAUHOI;
	}
	public String getNOIDUNG() {
		return NOIDUNG;
	}
	public void setNOIDUNG(String nOIDUNG) {
		NOIDUNG = nOIDUNG;
	}
	public String getMALINHVUC() {
		return MALINHVUC;
	}
	public void setMALINHVUC(String mALINHVUC) {
		MALINHVUC = mALINHVUC;
	}
	public String getMUCDO() {
		return MUCDO;
	}
	public void setMUCDO(String mUCDO) {
		MUCDO = mUCDO;
	}
	public String getA() {
		return A;
	}
	public void setA(String a) {
		A = a;
	}
	public String getB() {
		return B;
	}
	public void setB(String b) {
		B = b;
	}
	public String getC() {
		return C;
	}
	public void setC(String c) {
		C = c;
	}
	public String getD() {
		return D;
	}
	public void setD(String d) {
		D = d;
	}
	public String getDUNG() {
		return DUNG;
	}
	public void setDUNG(String dUNG) {
		DUNG = dUNG;
	}
	public cauhoicoso(String id,String macauhoi,String noidung,String malinhvuc,String mucdo,String A,String B,String C,String D,String dung)
	{
		super();
		this.id= id;
		this.MACAUHOI=macauhoi;
		this.NOIDUNG=noidung;
		this.MALINHVUC=malinhvuc;
		this.MUCDO=mucdo;
		this.A=A;
		this.B=B;
		this.C=C;
		this.D=D;
		this.DUNG=dung;
		
		
	
		
	}
	public cauhoicoso(){}
		
	public int Save()
	{
		int i=0;
		String sql = "INSERT INTO cauhoi VALUES("+"null"+",'"+MACAUHOI+"','"+NOIDUNG+"','"+MALINHVUC+"','"+MUCDO+"','"+A+"','"+B+"','"+C+"','"+D+"','"+DUNG+"')";
		i = Dbhandle.executeUpdate(sql);
		return i;
	}
	public static int Delete(String macauhoi)
	{
		int i = 0;
		String sql = "Delete from cauhoi where MACAUHOI='"+macauhoi+"'";
		i = Dbhandle.executeUpdate(sql);
		return i;
	}
	
	public int Update() 
	{
		int i = 0;
		String sql = "UPDATE cauhoi SET NOIDUNG='"+NOIDUNG+"', MALINHVUC='"+MALINHVUC+"', MUCDO = '"+MUCDO+"', A = '"+A+"',B='"+B+"',C = '"+C+"',D='"+D+"',DUNG='"+DUNG+"'  WHERE MACAUHOI='"+MACAUHOI+"'";
		i = Dbhandle.executeUpdate(sql);
		return i;
	}
	public static ResultSet SelectAll() throws SQLException
	{
		String sql="SELECT * FROM cauhoi";
		ResultSet rs= Dbhandle.executeQuery(sql);
		return rs;
	}
	public static ResultSet Selectone(String str) throws SQLException
	{
		String sql="SELECT * FROM cauhoi  where MUCDO="+"'"+str+"'"+"";
		ResultSet rs= Dbhandle.executeQuery(sql);
		return rs;
		
	}
	public static ResultSet SelectoneLV(String str) throws SQLException
	{
		String sql="SELECT * FROM cauhoi  where MALINHVUC="+"'"+str+"'"+"";
		ResultSet rs= Dbhandle.executeQuery(sql);
		return rs;
		
	}
	public static ResultSet SelectoneND(String str) throws SQLException
	{
		String sql="SELECT * FROM cauhoi  where NOIDUNG LIKE "+"'"+"%"+str+"%"+"'"+"";
		ResultSet rs= Dbhandle.executeQuery(sql);
		return rs;
		
	}
}
